//引入样式
require("../../assets/css/reset.css")
require('../../assets/css/normalize.css')
require('../../assets/fonts/iconfont.css')
require('../../assets/css/tabbar.less')
require('../../assets/css/navbar.less')
require('./sports_course.less');
//引入模块
const dom = require('../../utils/dom.js');
const axios = require('../../utils/axios.js')
document.addEventListener("DOMContentLoaded", function () {
    dom.tabbar("tabbar");
    dom.navbar('sports_course');
    axios.get('/api/train/courseList').then(res => {
        let courseArr = res.data.data;
        let newData = courseArr.shift();
        //渲染最新课程
        dom.get('.newcourse a').href = `sports_course_detail.html?id=` + newData.courseId;
        dom.get('.newcourse img').src = axios.defaults.baseURL + newData.imgurl
        dom.get('.newcourse h4').textContent = newData.name;
        dom.get('.newcourse p').textContent = newData.desc.slice(0, 12) + '...';

        // 渲染课程列表
        let html = '';
        courseArr.forEach(v => {
            html += `
                     <li>
                         <a href="sports_course_detail.html?id=${v.courseId}">
                             <img src=${axios.defaults.baseURL + v.imgurl}>
                             <h4>${v.name}</h4>
                             <p>${v.desc.slice(0, 12) + '...'}</p>
                         </a>
                     </li>
             `
        });
        dom.get('.course_list ul').innerHTML = html;
    })

})